package edu.winona.csclub.testing.generators;

import java.util.LinkedList;
import java.util.List;

import edu.winona.csclub.testing.core.Command;
import edu.winona.csclub.testing.core.Range;
import edu.winona.csclub.testing.core.Test;
import edu.winona.csclub.testing.core.TestCase;
import edu.winona.csclub.testing.core.Value;
import edu.winona.csclub.testing.core.Variable;
import edu.winona.csclub.testing.utils.RangedRandom;

/**
 * 
 * tests min+ and max-
 * 
 * @author chris lohfink
 *
 */
public class StupidCaseEnumProvider implements EnumProvider {

	public void generateTests(Command command, TestCase tests) {
		List<Variable> vars = command.getVariables();
		
		for( int j = 0 ; j < vars.size() ;j++){
			// add min+
				List<Value> values = new LinkedList<Value>();
				for( int i = 0 ; i < vars.size() ;i++){
					Range range = vars.get(i).getRange()[0]; // will only care about range.length > 0 for equiv class
					
					RangedRandom r = new RangedRandom(range.getMin()+2 ,range.getMax()-2 );
					if( j!=i )
						values.add( new Value( vars.get(i),""+r.nextInt()) ); // as long as it falls between min+ and max- dont care what this is
					else 
						values.add( new Value( vars.get(i),""+(range.getMin()+1)) ) ;
				}
				tests.addTest(new Test(command, values));
				values = new LinkedList<Value>();
			// add max+
				for( int i = 0 ; i < vars.size() ;i++){
					Range range = vars.get(i).getRange()[0]; // will only care about range.length > 0 for equiv class
					
					RangedRandom r = new RangedRandom(range.getMin()+2 ,range.getMax()-2 );
					if( j!=i )
						values.add( new Value( vars.get(i),""+r.nextInt()) ); // as long as it falls between min+ and max- dont care what this is
					else 
						values.add( new Value( vars.get(i),""+(range.getMax()-1)) ) ;
				}
				tests.addTest(new Test(command, values));
		}	
		
	}

}
